//
//  MYGMettingForumCell.swift
//  MYDoctor
//
//  Created by 小火科技 on 2024/5/29.
//

import UIKit

class MYGMettingForumCell: UITableViewCell {

    var sppeechModel:MYGAcademicSpeechModel? {
        didSet {
            guard let model = sppeechModel else {return}
            
            titleLabel.text = model.speechCn
            timeLabel.text = "时间：\(model.room.sessionTime)"
            mettingLabel.text = "会场：\(model.room.location)"
            forumLabel.text = "论坛：\(model.room.sessionCn)"
            forumLabel.isHidden = false
        }
    }
    
    var model:MYGAcademicModel? {
        didSet {
            guard let model = model else {return}
            
            titleLabel.text = model.sessionCn
            timeLabel.text = "时间：\(model.sessionTime)"
            mettingLabel.text = "会场：\(model.location)"
            forumLabel.isHidden = true
//            forumLabel.text = "论坛：\(model.room.sessionCn)"
        }
    }
    
    var isShow :Bool = false {
        didSet {
            forumLabel.isHidden = isShow
        }

    }
    
    // MARK: - init
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        contentView.backgroundColor = .white
        configUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    // MARK: - UI
    private func configUI() {
        contentView.backgroundColor = .white
        contentView.addSubview(titleLabel)
        contentView.addSubview(timeLabel)
        contentView.addSubview(mettingLabel)
        contentView.addSubview(nextImageView)
        contentView.addSubview(forumLabel)
        contentView.addSubview(line)
        
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(20)
            make.top.equalTo(22)
            make.height.equalTo(21)
            make.right.equalToSuperview().inset(20)
        }
        
        timeLabel.snp.makeConstraints { make in
            make.left.equalTo(titleLabel)
            make.top.equalTo(titleLabel.snp.bottom).offset(6)
            make.height.equalTo(20)
            make.right.equalToSuperview().inset(27)
        }
        mettingLabel.snp.makeConstraints { make in
            make.left.equalTo(titleLabel)
            make.top.equalTo(timeLabel.snp.bottom).offset(6)
            make.height.equalTo(20)
            make.right.equalToSuperview().inset(27)
        }
        
        nextImageView.snp.makeConstraints { make in
            make.width.height.equalTo(12)
            make.right.equalToSuperview().inset(20)
            make.centerY.equalTo(timeLabel)
        }
        
        forumLabel.snp.makeConstraints { make in
            make.left.equalTo(titleLabel)
            make.top.equalTo(mettingLabel.snp.bottom).offset(6)
            make.height.equalTo(20)
            make.right.equalToSuperview().inset(27)
        }
        
        line.snp.makeConstraints { make in
            make.height.equalTo(0.5)
            make.left.bottom.right.equalToSuperview()
        }
        
    }
   
    private lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.font = .medium(15)
        label.textColor = .rgba(70, 70, 70, 1)
        return label
    }()
    
    private lazy var timeLabel: UILabel = {
        let label = UILabel()
        label.font = .regular(14)
        label.textColor = .rgba(152, 152, 152, 1)
        return label
    }()
    
    private lazy var mettingLabel: UILabel = {
        let label = UILabel()
        label.font = .regular(14)
        label.textColor = .rgba(152, 152, 152, 1)
        return label
    }()
    
    private lazy var forumLabel: UILabel = {
        let label = UILabel()
        label.font = .regular(14)
        label.textColor = .rgba(152, 152, 152, 1)
        label.isHidden = true
        return label
    }()
    
    private lazy var nextImageView: UIImageView = {
        let imageV = UIImageView()
        imageV.image = UIImage(named: "re_next")
        return imageV
    }()

    private lazy var line:UIView = {
        let line = UIView()
        line.backgroundColor = .rgba(238, 238, 238, 1)
        return line
    }()
}
